package com.jeff.studyclient.util;

import java.net.URL;
import java.util.HashMap;
import java.util.Map;
import javax.swing.Icon;
import javax.swing.ImageIcon;

/** This class holds all image resources
 * 
 * @author syed.mustaffa
 */
public class ImageUtils {

	public final static String iconPath = "icons/";
	
	private static final Icon splashIcon = new ImageIcon(ImageUtils.class.getClassLoader().getResource(iconPath + "login-wall.png"));
	private static final Icon accountCategoryIcon = new ImageIcon(ImageUtils.class.getClassLoader().getResource(iconPath + "icon-colorpicker.png"));

	private static Map<String, Icon> icons = new HashMap<String, Icon>();

	public static URL getImageURL(String name) {
		return ImageUtils.class.getClassLoader().getResource(iconPath + name);
	}

	public static Icon getIcon(String name) {
		if (!icons.containsKey(name)) {
			ImageIcon icon = new ImageIcon(getImageURL(name));
			icons.put(name, icon);
		}
		return icons.get(name);
	}

	public static Icon getSplashIcon() {
		return splashIcon;
	}

	public static Icon getAccountCategoryIcon() {
		return accountCategoryIcon;
	}
}
